import React from 'react';
import  {Link} from 'react-router-dom'
import Muntil from 'until/mm.jsx'
import Product from 'service/produce-service.jsx'
import PageTitle from 'component/page-title/index.jsx'
import CategorySelector from "page/produce/index/category-selector.jsx";



//http://localhost:8080/manage/product/save.do?
// categoryId=1
// &name=三星洗衣机
// &subtitle=三星大促销
// &subImages=test.jpg,11.jpg,2.jpg,3.jpg
// &detail=detailtext
// &price=1000
// &stock=100
// &status=1


const _mm=new Muntil();
const _product=new Product();



class ProductSave extends React.Component{
    constructor(){
        super();
        this.state={
            categoryId: 0 ,       //二级分类id,当前id,如果为 0 即只有一级分类
            parentCategoryId :0   //一级分类id
        }
    }


    onChangeCategory(firstCategoryId,secondCatetory){
        console.log(firstCategoryId,secondCatetory)
    }
    render(){
        return(
           <div id="page-wrapper">
               <PageTitle title="添加商品"/>
               <div className="form-horizontal">
                   <div className="form-group">
                       <label className="col-md-2 control-label">商品名称</label>
                       <div className="col-md-5">
                           <input type="text" className="form-control"  placeholder="请输入商品名称" />
                       </div>
                   </div>
                   <div className="form-group">
                       <label  className="col-md-2 control-label">商品描述</label>
                       <div className="col-md-5">
                           <input type="text" className="form-control" placeholder="请输入商品描述"/>
                       </div>
                   </div>

                   <div className="form-group">
                       <label  className="col-md-2 control-label">请选择一级分类</label>
                       <CategorySelector  onChangeCategory={(firstCategoryId,secondCatetory)=>{this.onChangeCategory(firstCategoryId,secondCatetory)}}/>
                   </div>

                   <div className="form-group">
                       <label  className="col-md-2 control-label">商品价格</label>
                       <div className="col-md-3">
                           <div className="input-group">
                               <input type="text" className="form-control" placeholder="价格"/>
                               <div className="input-group-addon">元</div>
                           </div>
                       </div>
                   </div>

                   <div className="form-group">
                       <label  className="col-md-2 control-label">库存</label>
                       <div className="col-md-3">
                           <div className="input-group">
                               <input type="text" className="form-control" placeholder="商品库存"/>
                               <div className="input-group-addon">件</div>
                           </div>

                       </div>
                   </div>

                   <div className="form-group">
                       <label  className="col-md-2 control-label">商品图片</label>
                       <div className="col-md-3">
                          xxx
                       </div>
                   </div>

                   <div className="form-group">
                       <label  className="col-md-2 control-label">商品详情</label>
                       <div className="col-md-3">
                           xxx
                       </div>
                   </div>

                   <div className="form-group">
                       <div className="col-md-offset-2 col-md-10">

                           <button type="submit" className="btn btn-primary">Sign in</button>
                       </div>
                   </div>
               </div>
           </div>


        )
    }
}


export default ProductSave;